<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <head>
    <title>Hosts list</title>
  </head>

  <body>
    <div id="ctxtnav" class="nav"></div>

    <div id="content" class="hosts">
		<form action="/hosts/delete" method="post">
		<table class="hosts_table">
			<tr class="hosts_header">
				<td></td>
				<td>Name&nbsp;&nbsp;<a href="/hosts/sort_nd">&darr;</a> <a href="/hosts/sort_nu">&uarr;</a></td>
				<td>Mark&nbsp;&nbsp;<a href="/hosts/sort_md">&darr;</a> <a href="/hosts/sort_mu">&uarr;</a></td>
				<td>Description</td>
				<td>CPU</td>
				<td>RAM</td>
				<td>Disk</td>
				<td>OS</td>
				<td>IP&nbsp;&nbsp;<a href="/hosts/sort_id">&darr;</a> <a href="/hosts/sort_iu">&uarr;</a></td>
				<td>U</td>
				<td>KVM</td>
			</tr>
			<tr py:for="id, name, mark, description, cpu, ram, disk, os, ip, rack_unit, kvm, kvm_name in lists">
				<td class="delete"><input type="checkbox" name="delete" value="${id}" /></td>
				<td><a href="/hosts/edit_form?id=${id}">${name}</a></td>
				<td>${mark}</td>
				<td>${description}</td>
				<td>${cpu}</td>
				<td>${ram}</td>
				<td>${disk}</td>
				<td>${os}</td>
				<td>
<?python
from genshi.builder import tag
import re
def check_ip(ip, url):
	if re.match('10|192|172|127\.([\d]+)\.([\d]+)\.([\d]+)', ip):
		return tag.b('%s' % ip) 
	else:
		return tag.a('%s' % ip, href=url % ip, target="_blank")
?>
				<li py:for='addr in ip.split("\r\n")' class="host_list">
					${check_ip(addr, url)}
				</li>
				</td>
				<td>${rack_unit}</td>
				<td>
					<li py:for='addr, kname in zip(kvm.split("\r\n"), kvm_name.split("\r\n"))' class="host_list">
						<a href="${addr}">${kname}</a>
					</li> 
				</td>
			</tr>
		</table>
		<br />
		<input type="submit" value="Delete" />
		<input type="button" value="Add" onclick="document.location='/hosts/add_form';"/>
		</form>
    </div>
  </body>
</html>